﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>


<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
IF  Request.QueryString("Action")="login" Then
	call login
else
	call index
end if
end Function



Function index
	dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1
	dim rs,sql,Runtxt,id,classid
    		classid = Request("classid")
    		If classid = "" Then classid = 0
   		If Not IsNumeric(classid) Then classid = 0
    		classid = CLng(classid)
    		If classid < 0 Then classid = 0

	Runtxt=qingtian.RunStr
    		id = Request("id")    
    		If id = "" Then id = 1
   		If Not IsNumeric(id) Then id = 1
    		id = CLng(id)
    		If id < 1 Then id = 1

%>
	<card title="编辑文章"><p align="left">
<%
		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 *  FROM qingtian_viewli where id="&id&""
		rs.open sql,conn,1,1
		if not (rs.eof and rs.bof) then

		Dim path,FsoObj,tempfileOBJ,txt
		Path = server.mappath(Request.ServerVariables("SCRIPT_NAME"))
		Path=left(Path,instrrev(Path,"\" ) - 1 )
		path=Path & "/../" & RS("urls")


    		Set FsoObj=Server.CreateObject("Scripting.FileSystemObject")
		IF FSOObj.FileExists(path) = True then
   		Set tempfileOBJ = FsoObj.OpenTextFile(path, 1, 0, 0 )
    		While NOT tempfileOBJ.AtEndOfStream
			txt=txt & tempfileOBJ.ReadLine & vbNewLine 
    		Wend
		Set tempfileOBJ=Nothing
		end if
		Set FsoObj=Nothing
		if len(txt)>2 then txt=left(txt,len(txt)-2)


		dim rs2,sql2,i
%>
   	分类<select name="cid<%=Runtxt%>" value="<%=rs("classid")%>">
	<%
	  set rs2=server.CreateObject("adodb.recordset")
	  sql2="select id,name from qingtian_class where Ext=7"
	  rs2.open sql2,conn,1,1
	  if not (rs2.bof and rs2.eof) then
	  For i=1 to rs2.RecordCount
		%>
		<option value="<%=rs2("id")%>"><%=qingtian.utf8(rs2("name"))%></option>
		<%
	  Rs2.MoveNext
	  Next

	  end if
	  Rs2.close
	  set rs2=nothing
	%>
	</select><br/>
	文章推荐：
   	<select name="tuijian<%=Runtxt%>" value="<%=qingtian.FormatEdit(rs("tuijian"))%>">
	<%if  cint(rs("tuijian"))=0 then%>
	<option value="0">不推荐</option>
	<option value="1">推荐</option>
	<%else%>
	<option value="1">推荐</option>
	<option value="0">不推荐</option>
	<%end if%>
	</select><br/>

	文章标题：<br/>
	<input emptyok="true"  name="name<%=Runtxt%>"  value="<%=qingtian.FormatEdit(rs("name"))%>" type="text"/><br/>
	文章内容：<br/>
	<input emptyok="true"  name="txt<%=Runtxt%>"  value="<%=qingtian.FormatEdit(txt)%>" type="text"/><br/>
	金币购买：
   	<select name="vip<%=Runtxt%>" value="<%=qingtian.FormatEdit(rs("vip"))%>">
	<%if  cint(rs("vip"))=0 then%>
	<option value="0">否</option>
	<option value="1">是</option>
	<%else%>
	<option value="1">是</option>
	<option value="0">否</option>
	<%end if%>
	</select><br/>
	购买金币：<br/>
	<input emptyok="true"  name="zf<%=Runtxt%>"  value="<%=qingtian.FormatEdit(rs("zf"))%>" type="text"/><br/>
	VIP会员查看：
   	<select name="viphy<%=Runtxt%>" value="<%=qingtian.FormatEdit(rs("viphy"))%>">
	<%if  cint(rs("viphy"))=0 then%>
	<option value="0">否</option>
	<option value="1">是</option>
	<%else%>
	<option value="1">是</option>
	<option value="0">否</option>
	<%end if%>
	</select><br/>
	文章作者：<br/>
	<input emptyok="true"  name="zuozhe<%=Runtxt%>"  value="<%=qingtian.FormatEdit(rs("zuozhe"))%>" type="text"/><br/>
	文章来源：<br/>
	<input emptyok="true"  name="laiyuan<%=Runtxt%>"  value="<%=qingtian.FormatEdit(rs("laiyuan"))%>" type="text"/><br/>


	<anchor>确定提交
    	<go href="editviewlist.asp?Action=login&amp;page=<%=page%>&amp;id=<%=id%>&amp;classid=<%=classid%>&amp;sid=<%=sid%>" method='post'>
        <postfield name="cid" value="$(cid<%=Runtxt%>)"/>
        <postfield name="name" value="$(name<%=Runtxt%>)"/>
        <postfield name="tuijian" value="$(tuijian<%=Runtxt%>)"/>
        <postfield name="txt" value="$(txt<%=Runtxt%>)"/>
        <postfield name="vip" value="$(vip<%=Runtxt%>)"/>
        <postfield name="zf" value="$(zf<%=Runtxt%>)"/>
        <postfield name="zuozhe" value="$(zuozhe<%=Runtxt%>)"/>
        <postfield name="laiyuan" value="$(laiyuan<%=Runtxt%>)"/>
        <postfield name="viphy" value="$(viphy<%=Runtxt%>)"/>
        <postfield name="vipgm" value="$(vipgm<%=Runtxt%>)"/>
    	</go>
	</anchor><br/>
<%
		end if
		rs.Close
		Set rs = Nothing
%>

-------------<br/>
<a href='viewlist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>返回文章管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
End Function


Function login
	dim page
    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1

		dim rs,sql,errs,id,classid
    		classid = Request("classid")
    		If classid = "" Then classid = 0
   		If Not IsNumeric(classid) Then classid = 0
    		classid = CLng(classid)
    		If classid < 0 Then classid = 0

		dim cid,name,tuijian,txt,vip,zf,zuozhe,laiyuan,viphy,vipgm
        cid=Request.form("cid")
        name=Request.form("name")
        tuijian=Request.form("tuijian")
        txt=Request.form("txt")
        vip=Request.form("vip")
        zf=Request.form("zf")
        zuozhe=Request.form("zuozhe")
        laiyuan=Request.form("laiyuan")
  	viphy=TRim(Request.Form("viphy"))



    		id = Request("id")    
    		If id = "" Then id = 1
   		If Not IsNumeric(id) Then id = 1
    		id = CLng(id)
    		If id < 1 Then id = 1

		errs=""

		if len(name)=0  then errs=errs & "文章内容不能为空<br/>"
		if cid=""  then errs=errs&"分类不能为空<br/>"
		if not isnumeric(classid) then errs=errs&"分类必须为数字<br/>"
		if tuijian=""  then errs=errs&"推荐不能为空<br/>"
		if not isnumeric(tuijian) then errs=errs&"推荐必须为数字<br/>"
		if vip=""  then errs=errs&"VIP不能为空<br/>"
		if not isnumeric(vip) then errs=errs&"VIP必须为数字<br/>"
		if zf=""  then errs=errs&"金币不能为空<br/>"
		if not isnumeric(zf) then errs=errs&"金币必须为数字<br/>"
	if viphy=""  then errs=errs&"VIP会员查看不能为空<br/>"
	if not isnumeric(viphy) then errs=errs&"VIP会员查看必须为数字<br/>"


	%>
	<card id="login" title="编辑文章" ontimer="viewlist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>"><timer value="20"/>
		<p align="left">
	<%
	IF len(errs)=0 then


		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 *  FROM qingtian_viewli where id="&id&""
		rs.open sql,conn,1,3
		if not (rs.eof and rs.bof) then

					qingtian.CreateFolder left(Replace(rs("urls"),"\","/"),instrrev(rs("urls"),"/" ) - 1 )
					qingtian.delFile rs("urls")
					qingtian.CreateFile txt,rs("urls")

					rs("viphy")=viphy

					rs("tuijian")=tuijian
					rs("name")=name
					rs("classid")=cid
					rs("zf")=zf
					rs("vip")=vip
					rs("zuozhe")=zuozhe
					rs("laiyuan")=laiyuan
		rs.update()
		end if
		rs.Close
		Set rs = Nothing
		%>编辑文章成功!<br/><%

	else%>
		<%=errs%>
		<a href="editviewlist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;id=<%=id%>&amp;sid=<%=sid%>">返回修改</a><br/>
<%	end if
%>
<a href='viewlist.asp?classid=<%=classid%>&amp;page=<%=page%>&amp;sid=<%=sid%>'>返回文章管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function 


%>
